//PayNotifyModel
//2020-07-30 18:40:16

package models

import (
	"git.900sui.cn/kc/base/common/functions"
	"git.900sui.cn/kc/base/common/models/base"
	"git.900sui.cn/kc/kcgin/orm"
)

//表结构体
type PayNotifyModel struct {
	Model *base.Model
	Field PayNotifyModelField
}

//表字段
type PayNotifyModelField struct {
	T_table       string `default:"pay_notify"`
	F_id          string `default:"id"`
	F_order_sn    string `default:"order_sn"`
	F_pay_sn      string `default:"pay_sn"`
	F_pay_channel string `default:"pay_channel"`
	F_pay_type    string `default:"pay_type"`
	F_pay_amount  string `default:"pay_amount"`
	F_pay_fee     string `default:"pay_fee"`
	F_pay_time    string `default:"pay_time"`
	F_pay_status  string `default:"pay_status"`
	F_create_time string `default:"create_time"`
	F_pay_raw     string `default:"pay_raw"`
}

//初始化
func (p *PayNotifyModel) Init(ormer ...orm.Ormer) *PayNotifyModel {
	functions.ReflectModel(&p.Field)
	p.Model = base.NewModel(p.Field.T_table, ormer...)
	return p
}

//新增数据
func (p *PayNotifyModel) Insert(data map[string]interface{}) int {
	result, _ := p.Model.Data(data).Insert()
	return result
}

//获取单条数据
func (p *PayNotifyModel) GetByOrderSn(orderSn string) map[string]interface{} {
	if orderSn == "" {
		return map[string]interface{}{}
	}
	return p.Model.Where(map[string]interface{}{
		p.Field.F_order_sn: orderSn,
	}).Find()
}
